<template>
	<view class="login">
		<view class="backView">
			<image class="topImg" src="https://chongwu.aitaoba.net/storage/uploads/20231118/0965d03c743303189ced18707ae69772.png"></image>
			<button class="loginButton" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号</button>
		</view>
	</view>
</template>

<script>
	import {
		wxgetPhone
	} from "@/api/login.js"
	export default {
		data() {
			return {

			}
		},
		methods: {
			getPhoneNumber(e) {
				// console.log(e.detail, '手机号授权')
				let data = {iv:e.detail.iv,encryptedData:encodeURIComponent(e.detail.encryptedData)};
				wxgetPhone(data).then((res) => {
					// console.log(res, '看看拿到的手机号相关信息')
					if(res.code==200){
						// console.log('拿到手机号了')
				
						uni.switchTab({
							url:'/pages/index/index'
						})
						// uni.navigateBack({
						// 	delta:1
						// });
						
					
					}
				}).catch((res)=>{
					
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.login {
		width: 100%;
		display: flex;
		flex-direction: column;
	}

	.backView {
		width: 100%;

		height: 100vh;
		background: linear-gradient(180deg, #FAE24E 0%, rgba(255, 255, 255, 0) 100%);
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-top: 147rpx;
		box-sizing: border-box;

	}

	.topImg {
		width: 361rpx;
		height: 361rpx;
		background: gold;
	}

	.loginButton {
		width: 630rpx;
		height: 100rpx;
		background: #FFCE10;
		box-shadow: 0rpx 6rpx 10rpx 1rpx rgba(0, 0, 0, 0.1608);
		border-radius: 50rpx;
		font-size: 36rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #2E2908;
		text-align: center;
		line-height: 100rpx;
		margin-top: 188rpx;
	}
</style>
